package demo;
//编写一个Calculator类，不能在定义对象的同时初始化，分别实现加减乘除
 class  Calculator{
    private int num1;
    private int num2;

    public int getNum1() {
        return num1;
    }

    public void setNum1(int num1) {
        this.num1 = num1;
    }

    public int getNum2() {
        return num2;
    }

    public void setNum2(int num2) {
        this.num2 = num2;
    }
    public int add(){ //加
        return num1+num2;
    }
    public int sub(){//减
        return num1-num2;
    }
    public int mul(){//乘
        return num1*num2;
    }
    public double dev(){//除
        return num1*1.0/num2;
    }
}
public class Test{
    public static void main(String[] args) {
        Calculator calculator=new Calculator();
        calculator.setNum1(1);
        calculator.setNum2(2);
        System.out.println(calculator.add());
    }
}
